<template>
	<view class="wrapper">
		<!-- 个人资料 -->
		<view class="profile">
			<view class="meta">
				<image class="avatar" src="../../static/shuijiao.jpg"></image>
				<text class="nickname">{{app_nickname}}</text>
			</view>
		</view>

		<view class="orders" style="margin-top: 20rpx;">
			<image style="height: 48rpx;width: 48rpx;display: block;" src="../../static/quoted.svg"></image>
			<view class="main" @click="gotoFeeds('/pages/userModule/quotationRecord/quotationRecord')">
				<view class="title">报价记录</view>
				<image style="height: 48rpx;width: 48rpx;display: block;margin-right: 32rpx;" src="../../static/chevron-left.svg"></image>
			</view>
		</view>
		<view class="line"></view>
		<view class="orders" @click="gotoFeeds('/pages/userModule/company/company')">
			<image style="height: 48rpx;width: 48rpx;display: block;" src="../../static/company.svg"></image>
			<view class="main">
				<view class="title" @click="gotoFeeds('/pages/userModule/company/company')">公司信息</view>
				<image style="height: 48rpx;width: 48rpx;display: block;margin-right: 32rpx;" src="../../static/chevron-left.svg"></image>
			</view>
		</view>
		<view class="line"></view>
		<!-- <view class="orders">
			<image style="height: 48rpx;width: 48rpx;display: block;" src="../../static/common.svg"></image>
			<view class="main" @click="gotoFeeds('/pages/userModule/formula/index')">
				<view class="title">报价备注</view>
				<image style="height: 48rpx;width: 48rpx;display: block;margin-right: 32rpx;" src="../../static/chevron-left.svg"></image>
			</view>
		</view> -->
		<!-- 其它 -->
		<!-- <view class="orders" style="margin-top: 20rpx;">
			<image style="height: 48rpx;width: 48rpx;display: block;" src="../../static/feedba.svg"></image>
			<view class="main" @click="gotoFeeds('/pages/userModule/formula/index')">
				<view class="title">意见反馈</view>
				<image style="height: 48rpx;width: 48rpx;display: block;margin-right: 32rpx;" src="../../static/chevron-left.svg"></image>
			</view>
		</view> -->
		<view class="orders" style="margin-top: 20rpx;" @click="loginout">
			<!-- <image style="height: 48rpx;width: 48rpx;display: block;" src="../../static/feedba.svg"></image> -->
			<view class="main" @click="gotoFeeds('/pages/userModule/formula/index')" style="text-align: center;">
				<view class="title" style="font-size: 17px;text-align: center;width: 100%;">退出登录</view>
				<!-- <image style="height: 48rpx;width: 48rpx;display: block;margin-right: 32rpx;" src="../../static/chevron-left.svg"></image> -->
			</view>
		</view>
	</view>
</template>

<script>
	// 引入vuex
	import {
		mapState
	} from 'vuex';

	export default {
		data() {
			return {
				app_nickname: '',
			}
		},
		onLoad() {
			let userInfo = uni.getStorageSync('userInfo');
			if(!userInfo){
				uni.showToast({
					title: '登录失效,重新登录',//标题 必填
					icon: 'none',//图标
				    mask: false,//是否显示透明蒙层，防止触摸穿透，默认：false
				    duration: 2000,//提示的延迟时间，单位毫秒，默认：1500
				});
				setTimeout(function () {
					uni.navigateTo({
						url: '/pages/login/login'
					});
				}, 2000);
			}
			userInfo = JSON.parse(userInfo);
			
			console.log(userInfo);
			// this.userinfo = userInfo;
			this.app_nickname = userInfo.app_nickname;
		},
		// 得到属性userInfo
		computed: {
			...mapState(['userInfo'])
		},
		created() {
		},
		methods: {
			gotoFeeds(url) {
				// 可以跳多级目录
				uni.navigateTo({
					url
				});
			},
			loginout(){
				uni.clearStorageSync();
				uni.navigateTo({
					url: '/pages/login/login'
				});
			}
		}
	};
</script>

<style scoped lang="scss">
	Page {
		font-size: 14px;
	}

	.line {
		box-sizing: border-box;
		border: 1px solid rgb(231, 231, 231);
		margin-left: 1rem;
		position: absolute;
		width: 100%;
	}

	.wrapper {
		position: absolute;
		overflow: hidden;
		top: 0;
		bottom: 0;

		width: 100%;
		background-color: #F4F4F4;
	}

	.profile {
		height: 264rpx;
		background-color: #FFFFFF;
		display: flex;
		justify-content: flex-start;
		padding-left: 32rpx;
		align-items: center;

		.meta {
			display: flex;
			align-items: center;

			.avatar {
				display: block;
				width: 128rpx;
				height: 128rpx;
				border-radius: 50%;
				// border: 2rpx solid #fff;
				overflow: hidden;
			}

			.nickname {
				display: block;
				text-align: center;
				margin-left: 42rpx;
				font-size: 40rpx;
				font-family: PingFang SC, PingFang SC;
				font-weight: bold;
				color: #1A1A1A;
				line-height: 47rpx;
			}
		}
	}

	.orders {
		padding-left: 32rpx;
		background-color: #fff;
		height: 112rpx;
		display: flex;
		align-items: center;

		.title {
			padding-left: 20rpx;
			font-size: 30rpx;
		}

		.main {
			flex: 1;
			display: flex;
			justify-content: space-between;
		}
	}

	.address {
		line-height: 1;
		background-color: #fff;
		font-size: 30rpx;
		padding: 25rpx 0 25rpx 20rpx;
		margin: 10rpx 20rpx;
		color: #333;
		border-radius: 4rpx;
	}

	.extra {
		margin: 0 20rpx;
		background-color: #fff;
		border-radius: 4rpx;

		.item {
			line-height: 1;
			padding: 25rpx 0 25rpx 20rpx;
			border-bottom: 1rpx solid #eee;
			font-size: 30rpx;
			color: #333;
		}

		button {
			text-align: left;
			background-color: #fff;

			&::after {
				border: none;
				border-radius: 0;
			}
		}
	}

	.icon-arrow {
		position: relative;

		&::before {
			position: absolute;
			top: 50%;
			right: 20rpx;
			transform: translateY(-50%);
		}
	}
</style>